import React from 'react'
import {Button} from 'antd'

import LwjTable from 'components/LwjTable'
import {LwjDownload} from 'components'

const List = ({
  onExport,
  onShowDelete,
  onShowDetail,
  onShowEdit,
  rowSelection,
  onSelectArea,
  onSelectRows,
  getProvinces,
  getCitiesByProvince,
  getAreaByCity,
  ...tableProps
}) => {
  const columns = [
    {
      title: '#',
      dataIndex: 'index',
      key: 'index',
      width: 40,
      render: (text, record, index) => (index + 1)
    }, {
      title: '报表名称',
      dataIndex: 'reportName',
      key: 'reportName',
      width: 500
    }, {
      title: '报表模板',
      key: 'template',
      width: 100,
      render: (record) => (<LwjDownload title={'点击下载'} downloadIcon={'export'} targetUrl={record.templatePath}/>)
    }, {
      title: '查看',
      key: 'sql',
      width: 100,
      render: (record) => (<Button
        type="primary"
        shape="circle"
        icon="eye"
        onClick={e => onShowDetail(record)}/>)
    }, {
      title: '状态',
      key: 'enabled',
      dataIndex: 'enabled',
      width: 100,
      render: (text, record) => (
        <span >
          {record.enabled
            ? '禁用'
            : '启用'}
        </span >
      )
    }, {
      title: '操作',
      width: 150,
      render: (text, record) => (
        <span>
          <a onClick={e => onShowEdit(record)}>
            更新
          </a>
          {/* <Divider type="vertical"/> <a onClick={() => onShowDelete(record)}>
            删除
          </a> */}
        </span >
      )
    }
  ]

  const onChange = (value) => {
    console.log(value); // ["130000", "130300", "130303"]
  }

  const dataSource = [
    {
      "id": "0",
      "updateTime": 1499225724466,
      "createTime": 1499225724466,
      "version": 0,
      "enabled": false,
      "name": "资源组",
      "priority": -1,
      "description": "资源组根节点"
    }, {
      "id": "28d978977c4b414ea5101408c625d172",
      "updateTime": 1522201892981,
      "createTime": 1522201892981,
      "version": 0,
      "enabled": false,
      "name": "资源管理",
      "parentId": "0",
      "priority": 0
    }, {
      "id": "e7b042edf0854a24b75c16ed33e48b70",
      "updateTime": 1522201847353,
      "createTime": 1522201847353,
      "version": 0,
      "enabled": false,
      "name": "角色管理",
      "parentId": "0",
      "priority": 0
    }, {
      "id": "308ca22a7c364b0c9843bd2eb7195977",
      "updateTime": 1522201881219,
      "createTime": 1522201881219,
      "version": 0,
      "enabled": false,
      "name": "修改角色",
      "parentId": "e7b042edf0854a24b75c16ed33e48b70",
      "priority": 1
    }, {
      "id": "42f3c907e5bd4d21a87892da79e109ed",
      "updateTime": 1522201904778,
      "createTime": 1522201904778,
      "version": 0,
      "enabled": false,
      "name": "增加资源",
      "parentId": "28d978977c4b414ea5101408c625d172",
      "priority": 1
    }, {
      "id": "b73f0e195e4948798c33698b350ae88a",
      "updateTime": 1522201865666,
      "createTime": 1522201865666,
      "version": 0,
      "enabled": false,
      "name": "添加角色",
      "parentId": "e7b042edf0854a24b75c16ed33e48b70",
      "priority": 1
    }
  ]

  return (
    <div>
      {/* <LwjTree dataSource={dataSource} />
      <LwjArea
        dataSource="backEnd"
        getProvinces={getProvinces}
        getCitiesByProvince={getCitiesByProvince}
        getAreaByCity={getAreaByCity}
        onChange={onChange}
        width={100} /> */}
      <div>
        <LwjTable {...tableProps} columns={columns}/>
      </div>
    </div>
  )
}

export default List
